package com.newhis.service;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.newhis.entity.LoginInfo;
import org.springframework.stereotype.Service;


@Service
public class TokenService {

    /**
     * 根据登录信息产生JWT token
     * @param li
     * @return
     */
    public String getToken(LoginInfo li) {
        String token= JWT.create().withClaim("emp", li.getEmpId())
                .withClaim("bch", li.getBranchId())
                .sign(Algorithm.HMAC256(li.getPassword()));

        return token;
    }
}
